package com.chendx.store.order.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chendx.model.common.dtos.ResponseResult;
import com.chendx.model.common.enums.AppHttpCodeEnum;
import com.chendx.model.order.pojo.OrderItem;
import com.chendx.store.order.mapper.OrderItemMapper;
import com.chendx.store.order.service.OrderItemService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * Created by chendx on 2022/4/19.
 */
@Service
public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper,OrderItem> implements OrderItemService {

    @Override
    public ResponseResult pj(String id) {
        if (StringUtils.isEmpty(id)){
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);
        }
        OrderItem orderItem = getById(id);
        if (orderItem.getIsComment().equals("1")){
            orderItem.setIsComment("2");
        }else {
            orderItem.setIsComment("1");
        }
        updateById(orderItem);
        return ResponseResult.okResult(orderItem);
    }
}
